﻿Imports System.Data.OleDb
Imports System.Data.Entity.Validation

Public Class AddInfoAbout
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

    '<System.Web.Services.WebMethod>
    'Private Sub Disable(value As String, url As String)
    'End Sub

    Protected Sub Button3_Click(sender As Object, e As EventArgs)

        Try

            Dim oleDbConn As New OleDb.OleDbConnection(ConfigurationManager.ConnectionStrings("ConnectionString004").ConnectionString)
            Dim SqlString As String = "Insert into sms_info(about_website, contact_website, about_image1, about_image2,about_image3,about_image4,about_image5,about_image6) Values (@f1,@f2,@f3,@f4,@f5,@f6,@f7,@f8)"
            Dim filename As String
            Dim img1 As String
            Dim img2 As String
            Dim img3 As String
            Dim img4 As String
            Dim img5 As String
            Dim img6 As String


            If (fl1.HasFile) Then
                filename = System.DateTime.Now.GetHashCode().ToString()
                img1 = filename + fl1.FileName
                Try
                    fl1.PostedFile.SaveAs(Server.MapPath("~/Upload/") + img1)
                Catch exc As Exception
                End Try
            Else
                img1 = ""
            End If
            If (fl2.HasFile) Then
                filename = System.DateTime.Now.GetHashCode().ToString()
                img2 = filename + fl2.FileName
                Try
                    fl2.PostedFile.SaveAs(Server.MapPath("~/Upload/") + img2)
                Catch exc As Exception
                End Try
            Else
                img2 = ""
            End If

            If (fl3.HasFile) Then
                filename = System.DateTime.Now.GetHashCode().ToString()
                img3 = filename + fl3.FileName
                Try
                    fl3.PostedFile.SaveAs(Server.MapPath("~/Upload/") + img3)
                Catch exc As Exception
                End Try
            Else
                img3 = ""
            End If

            If (fl4.HasFile) Then
                filename = System.DateTime.Now.GetHashCode().ToString()
                img4 = filename + fl4.FileName
                Try
                    fl4.PostedFile.SaveAs(Server.MapPath("~/Upload/") + img4)
                Catch exc As Exception
                End Try
            Else
                img4 = ""
            End If
            If (fl5.HasFile) Then
                filename = System.DateTime.Now.GetHashCode().ToString()
                img5 = filename + fl5.FileName
                Try
                    fl5.PostedFile.SaveAs(Server.MapPath("~/Upload/") + img5)
                Catch exc As Exception
                End Try
            Else
                img5 = ""
            End If
            If (fl6.HasFile) Then
                filename = System.DateTime.Now.GetHashCode().ToString()
                img6 = filename + fl6.FileName
                Try
                    fl6.PostedFile.SaveAs(Server.MapPath("~/Upload/") + img6)
                Catch exc As Exception
                End Try
            Else
                img6 = ""
            End If

            Dim cmd As OleDbCommand = New OleDbCommand(SqlString, oleDbConn)

            cmd.CommandType = CommandType.Text
            cmd.Parameters.AddWithValue("@f1", about_website.Text)
            cmd.Parameters.AddWithValue("@f2", contact_website.Text)
            cmd.Parameters.AddWithValue("@f3", img1)
            cmd.Parameters.AddWithValue("@f4", img2)
            cmd.Parameters.AddWithValue("@f5", img3)
            cmd.Parameters.AddWithValue("@f6", img4)
            cmd.Parameters.AddWithValue("@f7", img5)
            cmd.Parameters.AddWithValue("@f8", img6)
            oleDbConn.Open()
            cmd.ExecuteNonQuery()

            ScriptManager.RegisterClientScriptBlock( _
             Me, _
             GetType(Page), _
             "script", _
             "returnempcode();", _
             True)

        Catch ex As DbEntityValidationException

        End Try
    End Sub
End Class